Skip to content

Conversation

@Om-Mishra7
Copy link

Complete Python implementation of the GraphX C++ library with comprehensive test coverage and usage documentation.

Files Added

  • graphx.py (162 lines) - Python implementation with Hash, Graph, and BFS classes
  • test_graphx.py (205 lines) - Complete test suite with 20+ test cases
  • usage-python.md (350+ lines) - Comprehensive usage guide and API reference

Key Features

  • Full support for directed and undirected weighted graphs
  • BFS traversal with distance tracking and reachability checks
  • Flexible node types (integers and tuples)
  • Type hints throughout
  • Zero external dependencies (standard library only)

Testing

All tests passing:

python test_graphx.py

Usage Example

from graphx import Graph, BFS

g = Graph(n=5, is_directed=False)
g.add_edge(0, 1, weight=5)
g.add_edge(1, 2, weight=3)

bfs = BFS(g)
bfs.run(source=0)
print(bfs.min_dist(2))  # Output: 2

Technical Details

  • Language: Python 3.6+
  • Dependencies: Standard library only
  • Performance: O(V + E) BFS traversal
  • Capacity: Up to 5,000,000 nodes

This code introduces a Hash class for mapping tuples to unique integer IDs and a Graph class that supports directed and undirected weighted graphs. Additionally, a BFS class is implemented for performing breadth-first search on the graph.
This file contains unit tests for the Hash, Graph, and BFS classes, covering various scenarios including directed and undirected graphs, edge additions, and BFS functionality.
Added a comprehensive usage guide for the GraphX Python library, including installation instructions, core components, quick start examples, detailed usage of classes, API reference, testing instructions, performance notes, common patterns, and limitations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant